package com.denlaku.longan.service.impl;

import com.denlaku.longan.qo.DataPermQuery;
import com.denlaku.longan.qo.Query;
import com.denlaku.longan.repository.DataTagSetRepository;
import com.denlaku.longan.service.DataTagSetService;
import com.denlaku.longan.service.DataTagRelService;
import com.denlaku.longan.vo.DataTagSet;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author tianx
 */
@Slf4j
@Service
public class DataTagSetServiceImpl implements DataTagSetService {
    @Autowired
    private DataTagSetRepository dataTagSetRepository;

    @Autowired
    private DataTagRelService dataTagRelService;

    @Override
    public void add(DataTagSet dataTagSet) {
        dataTagSetRepository.add(dataTagSet);
    }

    @Override
    public void update(DataTagSet dataTagSet) {
        dataTagSetRepository.update(dataTagSet);
    }

    @Override
    public DataTagSet get(Query query) {
        return dataTagSetRepository.get(query);
    }

    @Override
    public List<DataTagSet> list(DataPermQuery query) {
        return dataTagSetRepository.list(query);
    }

    @Override
    public List<DataTagSet> search(DataPermQuery query) {
        return dataTagSetRepository.search(query);
    }

    @Override
    public void delete(DataPermQuery query) {
        dataTagSetRepository.delete(query);
        query.setTagSetId(query.getId());
        query.setId(null);
        dataTagRelService.delete(query);
    }
}
